﻿<html>

<head>
    <title>品质检测-精工云MES系统移动端</title>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <link href="/JG/Content/jquery/weui/style/weui.min.css" rel="stylesheet" />
    <link href="/JG/Content/jquery/jquery-weui/css/jquery-weui.min.css" rel="stylesheet" />
    <link href="/JG/Content/css/bootstrap.min.css" rel="stylesheet" />
    <link href="/JG/Content/css/Global.css" rel="stylesheet" />
    <link rel="stylesheet" href="/JG/Content/css/QualityInspection.css?v=1">
    <link rel="stylesheet" href="/JG/Content/css/TabletsGlobal.css?v=1">
    <script src="/JG/Content/LocalConfigs.js"></script>
    <script src="/JG/Content/LocalUserInfo.js"></script>
    <style>
        [v-cloak] {
            display: none;
        }
    </style>
</head>

<body ontouchstart>
    <!--title部分-->
    <header class="header">
        <div class="empty">
            <span id="stations"></span>
        </div>
        <div class="item header_title">
            <a href="javascript:;">品质检测</a>
        </div>
        <div class="item item2">
            <div class="set">
                <!--<span class="glyphicon glyphicon-cog" style="font-size: 50px;color:#FFFFFF"></span>-->
                <span><img style="width:50px" src="/JG/Content/images/early.png" alt=""></span>
            </div>
            <div class="user_img" onclick="javascript:location.href='/JG/Home/Index.html'">
                <span class="back"><img src="/JG/Content/images/return.png" alt=""></span>
            </div>
            <div class="clean"></div>
        </div>
    </header>

    <div id="MainPage" class="MainPage" v-cloak>
        <div class="input-group" style="text-align:center;font-size:18px;">
            <label class="input-group-addon" for="BarCode">SN码</label>
            <input type="text" class="form-control" maxlength="50" v-model="BarCode" placeholder="扫描或输入SN码回车"
                id="BarCode" :disabled="IsDisable" />
        </div>
        <div id="tab2" class="weui-tab__bd-item">
            <div class="left">
                <ul class="list-group">
                    <!-- <li class="list-group-item" v-if="CurrProcessName">当前工序&nbsp;&nbsp;{{CurrProcessName}}</li> -->
                    <li class="list-group-item">当前SN码&nbsp;&nbsp;{{CurrBarCode}}
                    </li>
                    <li class="list-group-item">
                        任务单号&nbsp;&nbsp;{{FormData.TaskCode}}
                    </li>
                    <!-- <li class="list-group-item">
                        产品码&nbsp; &nbsp;{{FormData.InvBarCode}}
                    </li> -->
                    <li class="list-group-item">
                        产品编码&nbsp; &nbsp;{{FormData.InvCode}}
                    </li>
                    <li class="list-group-item">
                        产品名称&nbsp; &nbsp;{{FormData.InvName}}
                    </li>
                    <li class="list-group-item">
                        产品型号&nbsp; &nbsp;{{FormData.InvStd}}
                    </li>
                    <li class="list-group-item">
                        订单号码/内部订单号&nbsp;&nbsp;{{FormData.OrderCode}}/{{FormData.ProcessCode}}
                    </li>
                    <!-- <li class="list-group-item">
                        流程卡号&nbsp; &nbsp;{{FormData.ProcessCode}}
                    </li> -->
                    <li class="list-group-item">
                        订单数量/任务数量&nbsp;&nbsp;{{FormData.OrderNum}}/{{FormData.TaskQty}}
                    </li>
                    <li class="list-group-item" >
                        <!-- 投入数量&nbsp;&nbsp;{{FormData.InputQty}} -->
                        投入数量/已扫数量&nbsp;&nbsp;{{FormData.InputQty}}/{{ScanCodeNum}}
                    </li>
                    <!-- <li class="list-group-item">
                        已扫数量&nbsp;&nbsp;{{ScanCodeNum}}
                    </li> -->
                </ul>
            </div>

            <div class="right  panel panel-default">
                <ul class="nav nav-tabs">
                    <li class="active">
                        <a href="#OperateRecord" data-toggle="tab">操作记录</a>
                    </li>
                    <li>
                        <a href="#Swiper" data-toggle="tab">操作指导</a>
                    </li>
                </ul>
                <div class="tab-content tabs">
                    <div class="tab-pane fade in active" id="OperateRecord">
                        <ul style="height:100%;overflow-y:auto;">
                            <li style="font-size: 1.2em" v-for="(item,index) in OperateRecord"
                                :style="{'color':item.Status?'blue':'red'}">
                                {{item.Content}}
                            </li>
                        </ul>
                    </div>
                    <div class="tab-pane fade" id="Swiper">
                        <div class="swiper-container">
                            <div class="swiper-wrapper" id="Top_Swiper">
                            </div>
                            <div class="swiper-pagination"></div>
                        </div>
                    </div>
                </div>
            </div>
            <!--弹窗部分-->
            <div class="dialog">
                <span><img src="/JG/Content/images/timg.jpg" alt="关闭"></span>
                <div class="dialog_img"><img src="" id="ShowImg" alt=""></div>
            </div>
        </div>
        <div class="row" style="margin-left:5px">
            <!-- <button class="btn1 btn btn-success" type="button" v-if="DefectiveItemData.length>0" style="margin-top:10px;margin-left:15px;height:65px;width:115px"
                v-on:click="PassSubmitData()" :disabled="IsSubmit">
                PASS
            </button> -->
            <!--文字限长6个字符串-->
            <button type="button" v-for="(item,index) in DefectiveItemData" class="btn2 btn btn-warning" role="button"
                style="font-size:1.2em;margin-top:10px;margin-left:15px;height:65px;width:115px"
                v-on:click="SubmitDetectionItem(item)">
                {{item.ItemName}}
                <span>
                    <img src="/JG/Content/images/yixuan.png" style="display: none" :id="item.ID" />
                </span>
            </button>
            <!-- <button class="btn3 btn btn-danger" type="button" v-if="DefectiveItemData.length>0" style="margin-top:10px;margin-left:15px;height:75px;width:115px"
                v-on:click="SubmitData()" :disabled="IsSubmit">
                提 交
            </button> -->
        </div>

        <div class="panel panel-default over_station">
            <div class="panel-heading panel-heading1">
                过站记录
            </div>
            <table class="table">
                <thead>
                    <tr>
                        <th>序号</th>
                        <th>SN码</th>
                        <th>产品</th>
                        <th>过站时间</th>
                        <th>操作人</th>
                        <th>过站状态</th>
                    </tr>
                </thead>
                <tbody>
                    <tr v-for="(item,index) in StationRecord">
                        <td>{{index+1}}</td>
                        <td>{{item.BarCode}}</td>
                        <td>{{item.InvName}}\{{item.InvStd}}</td>
                        <td>{{item.StationTime}}</td>
                        <td>{{item.Operator}}</td>
                        <td><span :style="item.PassState=='Pass'?'color:green':'color:red'">{{item.PassState}}</span>
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
    </div>

    <script src="/JG/Content/jquery/jquery-3.2.1.min.js"></script>
    <script src="/JG/Content/jquery/jquery-weui/js/jquery-weui.min.js"></script>
    <script src="/JG/Content/bootstrap.min.js"></script>
    <script src="/JG/Content/Utils.js?v=1"></script>
    <script src="/JG//Content//AudioUtils.js"></script>
    <script src="/JG/Content/Common.js"></script>
    <script src="/JG//Content/Station.js"></script>
    <script src="/JG/Content/jquery/jquery-weui/js/swiper.min.js"></script>
    <script src="/JG/Content/jquery/fastclick.js"></script>
    <script src="/JG/Content/bootstrap/bootbox/bootbox.min.js"></script>
    <script src="/JG/Content/bootstrap/bootbox/bootbox.locales.min.js"></script>
    <script>
        $(function () {
            FastClick.attach(document.body);
            Station.Init(".header");
            var stations = LocalUserInfo.GetUserInfo();
            $("#stations").html(stations.ProductionLineName + " - " + stations.StationName);
        });
        //操作指导部分图片弹窗部分
        function popup(e) {
            //debugger;
            //弹出背景

            //关闭文字字体大小
            // $(".dialog>span").css({
            //     'position': 'absolute',
            //     'right': '.3em',
            //     'font-size':'5em',



            // })
            $("#ShowImg")[0].src = e.src;
            $(".dialog").fadeIn();

            $(".dialog>span").click(function () {
                $(".dialog").fadeOut();
            })
        }
    </script>
    <script src="/JG/Content/vue-v2.34.js"></script>
    <script type="text/javascript">
        var vmPage = new Vue({
            el: "#MainPage",
            data: {
                CurrProcessType: "GXLX005", //当前工序类型
                CurrProcessCode: "",  //当前工序编码
                CurrProcessName: "",  //当前工序名称
                CurrProcessIndex: 0,   //当前工序顺序
                ScanCodeNum: 0,        //扫码数量
                CurrBarCode: "",       //当前条码
                BarCode: "",
                IsDisable: false,
                IsSubmit: true,//是否Pass
                FormData: {
                    ScheduleID: "", //排产单ID
                    TaskCode: "",   //任务号
                    TaskQty: "", //任务数量
                    InputQty: 0, //投入数量
                    InvCode: "",
                    InvName: "",
                    InvStd: "",
                    InvBarCode: "",
                    InvProcessType: "",
                    SOPImagePaths: [],
                    OrderCode: "",//订单号码
                    OrderNum: "",//订单数量
                    ProcessCode: "",//流程卡号
                },
                DefectiveItemData: [],
                SelectItemData: [],
                StationRecord: [],
                OperateRecord: [],
                MaxOperatingRecordNum: "",//操作记录显示最大条数
            },
            mounted: function () {
                var currSelf = this;
                $("#BarCode").bind("keypress", currSelf.SearchBarCode);
                $("#BarCode").focus();
                Utils.AutoBarCodeFocus();
                var data = MaxOperatingRecord();
                if (data.IsSuccess && data.Data) {
                    currSelf.MaxOperatingRecordNum = data.Data;
                }

                $.showLoading();
                $.ajax({
                    type: "post",
                    url: LocalConfig.SrvPath + "/jgmes/commonAction!getCurrentProductByCxCp.action",
                    data: {
                        userCode: LocalUserInfo.GetUserInfo().UserCode, mac: LocalUserInfo.GetUserInfo().Mac,
                        cxCode: LocalUserInfo.GetUserInfo().ProductionLineCode
                    },
                    dataType: "json",
                    success: function (ret) {
                        var retData = ReturnData(ret);
                        if (retData.IsSuccess && retData.Data) {
                            currSelf.SetBasetData(retData);
                            //获取当前已扫码数量
                            var NumData = GetCountScan(currSelf.FormData.ScheduleID);
                            if (NumData.IsSuccess && NumData.Data) {
                                currSelf.ScanCodeNum = NumData.Data;
                            }
                        }
                        //不良项
                        if (currSelf.FormData.InvCode) {
                            $.ajax({
                                type: "post",
                                async: false,
                                cache: true,
                                url: LocalConfig.SrvPath + "/jgmes/commonAction!getGXBLXMList.action",
                                data: { userCode: LocalUserInfo.GetUserInfo().UserCode, mac: LocalUserInfo.GetUserInfo().Mac, cpCode: currSelf.FormData.InvCode },
                                dataType: "json",
                                success: function (ret) {
                                    var retData = ReturnData(ret);
                                    if (retData.IsSuccess) {
                                        if (retData.Data) {
                                            for (var i in retData.Data) {
                                                var element = retData.Data[i];
                                                currSelf.DefectiveItemData.push({ ID: element.GXBLX_BLXBH, ItemName: element.GXBLX_BLXMC });
                                            }
                                        } else {
                                            var content = "未找到产品【" + currSelf.FormData.InvName + "】相关的不良项目";
                                            currSelf.SetOperateRecord(content, false);
                                            $.toptip(content, Utils.ToptipWaitTime.Warning, "warning");
                                        }
                                    }
                                },
                                error: function (xhr, status, err) {
                                    console.error(status);
                                    $.alert("请求失败");
                                }
                            });
                        }
                    }, error: function (xhr, status, errorThrown) {
                        $.alert("请求失败");
                        console.error(status);
                    }, complete: function () {
                        $.hideLoading();
                    }
                });
            },
            methods: {
                InitData: function (barCode) {
                    var currSelf = this;
                    $.showLoading();
                    $.ajax({
                        type: "post",
                        url: LocalConfig.SrvPath + "/jgmes/commonAction!getCurrentProductByCxCp.action",
                        data: {
                            userCode: LocalUserInfo.GetUserInfo().UserCode, mac: LocalUserInfo.GetUserInfo().Mac,
                            cxCode: LocalUserInfo.GetUserInfo().ProductionLineCode,
                            barCode: barCode,
                        },
                        dataType: "json",
                        success: function (ret) {
                            var retData = ReturnData(ret);
                            if (retData.IsSuccess && retData.Data) {
                                currSelf.SetBasetData(retData);

                            }
                            //不良项
                            if (currSelf.FormData.InvCode) {
                                $.ajax({
                                    type: "post",
                                    async: false,
                                    cache: true,
                                    url: LocalConfig.SrvPath + "/jgmes/commonAction!getGXBLXMList.action",
                                    data: { userCode: LocalUserInfo.GetUserInfo().UserCode, mac: LocalUserInfo.GetUserInfo().Mac, cpCode: currSelf.FormData.InvCode },
                                    dataType: "json",
                                    success: function (ret) {
                                        var retData = ReturnData(ret);
                                        if (retData.IsSuccess) {
                                            currSelf.DefectiveItemData = [];
                                            if (retData.Data) {
                                                for (var i in retData.Data) {
                                                    var element = retData.Data[i];
                                                    currSelf.DefectiveItemData.push({ ID: element.GXBLX_BLXBH, ItemName: element.GXBLX_BLXMC });
                                                }
                                            } else {
                                                var content = "未找到产品【" + currSelf.FormData.InvName + "】相关的不良项目";
                                                currSelf.SetOperateRecord(content, false);
                                                $.toptip(content, Utils.ToptipWaitTime.Warning, "warning");
                                            }
                                        }
                                    },
                                    error: function (xhr, status, err) {
                                        console.error(status);
                                        $.alert("请求失败");
                                    }
                                });
                            }
                        }, error: function (xhr, status, errorThrown) {
                            $.alert("请求失败");
                            console.error(status);
                        }, complete: function () {
                            $.hideLoading();
                        }
                    });
                },
                SetOperateRecord: function (content, status) {
                    var currSelf = this;
                    var content = (new Date().Format("hh:mm:sss")) + ' ' + content;
                    currSelf.OperateRecord.splice(0, 0, { Content: content, Status: status });
                    if (currSelf.OperateRecord.length > currSelf.MaxOperatingRecordNum) {
                        currSelf.OperateRecord.splice(currSelf.MaxOperatingRecordNum)
                    }
                },
                SetInputQuantity: function (err, data) {
                    var currSelf = this;
                    if (!err && data && data.IsSuccess) {
                        currSelf.FormData.InputQty = data.Data;
                    }
                },
                SetBasetData: function (retData) {
                    var currSelf = this;

                    currSelf.FormData.ScheduleID = retData.Data.JGMES_PLAN_SCRW_ID;
                    currSelf.FormData.TaskCode = retData.Data.SCRW_RWDH;
                    currSelf.FormData.InvCode = retData.Data.SCRW_CPBH;
                    currSelf.FormData.InvName = retData.Data.SCRW_NAME;
                    currSelf.FormData.InvStd = retData.Data.SCRW_CPGG;
                    currSelf.FormData.LineCode = retData.Data.SCRW_CXBM;
                    // currSelf.FormData.LineCode = retData.Data.SCRW_CXMC;
                    currSelf.FormData.TaskQty = retData.Data.SCRW_PCSL;
                    currSelf.FormData.OrderCode = retData.Data.SCRW_DDHM;
                    currSelf.FormData.OrderNum = retData.Data.SCRW_DDSL;
                    currSelf.FormData.ProcessCode = retData.Data.SCRW_LCKH;

                    //获取当前用户当前产品的工序
                    var data = GetCurrentProcess(currSelf.FormData.InvCode);
                    // //获取当前已扫码数量
                    // var NumData = GetCountScan(currSelf.FormData.ScheduleID);
                    // if (NumData.IsSuccess && NumData.Data) {
                    //     currSelf.ScanCodeNum = NumData.Data;
                    // }

                    if (data.IsSuccess && data.Data) {
                        currSelf.FormData.InvProcessType = data.Data.GXGL_GXLX_NAME;
                        currSelf.CurrProcessCode = data.Data.GXGL_GXNUM;
                        currSelf.CurrProcessName = data.Data.GXGL_GXNAME;

                        currSelf.CurrProcessIndex = data.Data.GXGL_GXSXH;  //首工位为1,大于1显示投入数量
                        if (Utils.TabletsGlobalParam.IsOpenInputQtyTask) {
                            GetInputQuantity(currSelf.FormData.InvCode, currSelf.FormData.ScheduleID, currSelf.SetInputQuantity);

                            var ret1 = setInterval(function () {
                                GetInputQuantity(currSelf.FormData.InvCode, currSelf.FormData.ScheduleID, currSelf.SetInputQuantity);
                            }, Utils.TabletsGlobalParam.InputQtyTaskFrequency);
                        }

                        if (data.Data.GXGL_SOP && data.Data.GXGL_SOP.length > 0) {
                            var htmlAppend = "";
                            var imgSOPs = JSON.parse(data.Data.GXGL_SOP);
                            for (var index in imgSOPs) {
                                var item = imgSOPs[index];
                                htmlAppend += "<div class='swiper-slide'><img onclick='popup(this)' style='width:100%;height:100%' src='" + LocalConfig.SrvPath + item.path + "'/></div>";
                            }
                            $("#Top_Swiper").append(htmlAppend);
                            //3.11 自动轮播
                            var index = 0;
                            /*当鼠标放到顺序按钮上时：
                            1.将当前这个顺序按钮增加样式为红色背景
                            2.移除周围其他同级元素红色背景样式
                            3.获取当前顺序按钮的index
                            4.通过index获取该位置图片
                            5.一秒钟渐入该图片
                            6.一秒钟渐出其他相邻图片
                            7.防止移动过快导致的效果闪现，使用stop方法
                            */
                            $("#Swiper div>span").mousemove(function () {
                                $(this).addClass("swiper-pagination-bullet-active").siblings().removeClass("swiper-pagination-bullet-active");
                                index = $(this).index();
                                $("#Top_Swiper div").eq(index).stop().fadeIn(1000).siblings().stop().fadeOut(0);
                            });
                            var len = $('#Top_Swiper div').length;
                            var time = setInterval(move, 3000);

                            function move() {
                                index++;
                                if (index == len) {
                                    index = 0;
                                }
                                $('#Swiper div>span').eq(index).addClass("swiper-pagination-bullet-active").siblings().removeClass("swiper-pagination-bullet-active");
                                $('#Top_Swiper div').eq(index).stop().fadeIn(1000).siblings().stop().fadeOut(0);
                            }

                            /*当鼠标划入、划出轮播图区域时：
                            1.划入时停止自动轮播
                            2.划出时继续自动轮播
                            */
                            $("#Swiper").hover(function () {
                                clearInterval(time);
                            },
                                function () {
                                    time = setInterval(move, 3000);
                                });
                            if (imgSOPs && imgSOPs.length > 1) {
                                $(".swiper-container").swiper({
                                    loop: true,
                                    autoplay: 3000
                                });
                            }
                        }
                    }
                },
                SearchBarCode: function (event) {
                    var currSelf = this;
                    if (event.which == 13) {
                        var barCode = currSelf.BarCode;
                        currSelf.BarCode = "";
                        var showMsg;
                        currSelf.IsDisable = true;
                        // if (currSelf.IsSubmit == false) //继续扫码自动PASS
                        //     currSelf.PassSubmitData(currSelf.FormData.InvBarCode, false);

                        if (!currSelf.FormData.InvCode) {
                            showMsg = '当前产线无产品在生产中';
                            $.toptip(showMsg, Utils.ToptipWaitTime.Warning, "warning");
                            currSelf.SetOperateRecord(showMsg, false);
                            AudioUtils.Play(AudioUtils.ScanCodeFail);
                        } else if (currSelf.CurrProcessType != currSelf.FormData.InvProcessType) {
                            showMsg = '工序类型不匹配不能过站,请核对!';
                            $.toptip(showMsg, Utils.ToptipWaitTime.Warning, "warning");
                            currSelf.SetOperateRecord(showMsg, false);
                            AudioUtils.Play(AudioUtils.ScanCodeFail);
                        } else if (!barCode || barCode.length <= 0) {
                            showMsg = 'SN码不能为空';
                            $.toptip(showMsg, Utils.ToptipWaitTime.Warning, "warning");
                            currSelf.SetOperateRecord(showMsg, false);
                            AudioUtils.Play(AudioUtils.ScanCodeFail);
                        } else {
                            var IsCheckBarCode = CheckProductBarCode(currSelf.FormData.InvCode, barCode, currSelf.FormData.ScheduleID);//校验或换产
                            if (IsCheckBarCode.IsSuccess) {
                                currSelf.CurrBarCode = barCode;
                                currSelf.IsSubmit = false;
                                currSelf.FormData.InvBarCode = currSelf.CurrBarCode;
                                currSelf.SetOperateRecord(currSelf.CurrBarCode + ",扫码成功", true);
                                AudioUtils.Play(AudioUtils.ScanCodeSuccess);
                                if (currSelf.SelectItemData && currSelf.SelectItemData.length > 0) {
                                    currSelf.SubmitData();
                                }
                                else currSelf.PassSubmitData();
                            } else {
                                AudioUtils.Play(AudioUtils.ScanCodeFail);
                                currSelf.SetOperateRecord(barCode + "," + IsCheckBarCode.message, false);
                                // if (IsCheckBarCode.ErrorCode == 10199) {
                                //     currSelf.SetBasetData(IsCheckBarCode.Data);
                                //     currSelf.SetOperateRecord("生产线已经更换产品{" + currSelf.FormData.InvName + "},请重新扫码", false);
                                // }
                                if (IsCheckBarCode.ErrorCode == 10199) { //换产
                                    currSelf.SetOperateRecord("生产线任务单{" + currSelf.FormData.TaskCode + "}已经更换,请重新扫码", false);
                                    currSelf.InitData(barCode);
                                    // bootbox.confirm({
                                    //     message: "是否进行换产？", buttons: {
                                    //         confirm: {
                                    //             label: '是',
                                    //             className: 'btn-success'
                                    //         },
                                    //         cancel: {
                                    //             label: '否',
                                    //             className: 'btn-danger'
                                    //         }
                                    //     }, callback: function (result) {
                                    //         if (result) {

                                    //             currSelf.InitData(barCode);
                                    //         }
                                    //     }
                                    // });

                                }
                            }
                        }
                        currSelf.IsDisable = false;
                    }
                },
                PassSubmitData: function () {
                    var currSelf = this;
                    $.showLoading();
                    var InvBarCode = currSelf.CurrBarCode;
                    currSelf.IsSubmit = true;
                    var jsonStr = JSON.stringify({ "BGSJ_TMH": InvBarCode, "BGSJ_CPBH": currSelf.FormData.InvCode, "BGSJ_SL": 1, "BGSJ_SCRWID": currSelf.FormData.ScheduleID, "BGSJ_PDJG_CODE": "PDJG01" });

                    var record = { BarCode: InvBarCode, InvName: currSelf.FormData.InvName, InvStd: currSelf.FormData.InvStd, StationTime: (new Date()).toLocaleTimeString(), Operator: LocalUserInfo.GetUserInfo().UserName, PassState: "Pass" };

                    $.ajax({
                        type: "post",
                        url: LocalConfig.SrvPath + "/jgmes/commonAction!doJsonSaveBGSJAll.action",
                        data: { "userCode": LocalUserInfo.GetUserInfo().UserCode, "mac": LocalUserInfo.GetUserInfo().Mac, "jsonStr": jsonStr },
                        dataType: "json",
                        success: function (ret) {
                            var retData = ReturnData(ret);
                            if (retData.IsSuccess) {
                                currSelf.ScanCodeNum++;
                                showMsg = InvBarCode + ",过站成功!";
                                $.toptip(showMsg, Utils.ToptipWaitTime.Success, 'success');
                                AudioUtils.Play(AudioUtils.OutStationSuccess);
                                currSelf.SetOperateRecord(showMsg, true);

                            } else {
                                showMsg = InvBarCode + ",过站失败";
                                record.PassState = "过站失败";
                                AudioUtils.Play(AudioUtils.OutStationFail);
                                currSelf.SetOperateRecord(showMsg + ",失败原因:" + retData.message, false);
                            }
                            currSelf.StationRecord.splice(0, 0, record);
                        }, error: function (xhr, status, errorThrown) {
                            console.error(status);
                            $.alert("请求过程中发生异常");
                        }, complete: function () {
                            $.hideLoading();
                        }
                    });
                },
                SubmitData: function () {
                    var currSelf = this;
                    var showMsg;
                    if (!currSelf.SelectItemData || currSelf.SelectItemData.length == 0) {
                        showMsg = "请选择不良项目!";
                        $.toptip(showMsg, Utils.ToptipWaitTime.Warning, "warning");
                        currSelf.SetOperateRecord(showMsg, false);
                    }
                    else {
                        currSelf.IsSubmit = true;
                        $.showLoading();
                        var jsonStr = JSON.stringify({ "BGSJ_TMH": currSelf.FormData.InvBarCode, "BGSJ_CPBH": currSelf.FormData.InvCode, "BGSJ_SL": 1, "BGSJ_SCRWID": currSelf.FormData.ScheduleID, "BGSJ_PDJG_CODE": "PDJG02" });
                        var jsonStrDetail = [];

                        if (currSelf.SelectItemData && currSelf.SelectItemData.length > 0) {
                            for (var i in currSelf.SelectItemData) {
                                var element = currSelf.SelectItemData[i];
                                jsonStrDetail.push({ "BGSJZB_BLBH": element.ID, "BGSJZB_BLMC": element.ItemName });
                            }
                        }
                        var record = { BarCode: currSelf.FormData.InvBarCode, InvName: currSelf.FormData.InvName, InvStd: currSelf.FormData.InvStd, StationTime: (new Date()).toLocaleTimeString(), Operator: LocalUserInfo.GetUserInfo().UserName, PassState: "已提交" };

                        $.ajax({
                            type: "post",
                            url: LocalConfig.SrvPath + "/jgmes/commonAction!doJsonSaveBGSJAll.action",
                            data: { "userCode": LocalUserInfo.GetUserInfo().UserCode, "mac": LocalUserInfo.GetUserInfo().Mac, "jsonStr": jsonStr, "jsonStrDetail": JSON.stringify(jsonStrDetail) },
                            dataType: "json",
                            success: function (ret) {
                                var retData = ReturnData(ret);
                                if (retData.IsSuccess) {
                                    currSelf.ScanCodeNum++;
                                    showMsg = currSelf.FormData.InvBarCode + ",提交成功";
                                    $.toptip(showMsg, Utils.ToptipWaitTime.Success, 'success');
                                    currSelf.SetOperateRecord(showMsg, true);
                                    AudioUtils.Play(AudioUtils.SubmitSuccess);
                                    $.each(currSelf.SelectItemData, function (i, item) {
                                        $("#" + item.ID).hide();
                                        //currSelf.SelectItemData.splice(i, 1);
                                    });
                                    currSelf.SelectItemData = [];
                                } else {
                                    showMsg = currSelf.FormData.InvBarCode + ",提交失败";
                                    AudioUtils.Play(AudioUtils.SubmitFail);
                                    record.PassState = "提交失败";
                                    $.toptip(showMsg, Utils.ToptipWaitTime.Error, 'error');
                                    currSelf.SetOperateRecord(showMsg + retData.message, false);
                                }
                                currSelf.StationRecord.splice(0, 0, record);
                            }, error: function (xhr, status, errorThrown) {
                                console.error(status);
                                $.alert("提交过程中发生异常");
                            }, complete: function () {
                                $.hideLoading();
                                $("#BarCode").focus();
                            }
                        });
                    }
                },
                SubmitDetectionItem: function (item) {
                    var currSelf = this;
                    if ($("#" + item.ID)[0].style.display == "none") {
                        $("#" + item.ID).show();
                        currSelf.SelectItemData.push(item);
                    } else {
                        for (var index in currSelf.SelectItemData) {
                            if (currSelf.SelectItemData[index].ID == item.ID) {
                                currSelf.SelectItemData.splice(index, 1);
                                $("#" + item.ID).hide();
                                return;
                            }
                        }
                    }
                    $("#BarCode").focus();
                }
            },
        });
    </script>
</body>

</html>